from src.game.entity.projectile import EntityProjectile
from src.game.entity.living import EntityLiving
from src.game.buff.damage import DamageBuff
from src.handler.sprite import SpriteHandler

class EntityFlame(EntityProjectile):
    
    def __init__(self):
        EntityProjectile.__init__(self)
        self.collision = True
    
    def render(self, client, viewport):
        EntityProjectile.render(self, client, viewport)
        localX, localY = viewport.globalToLocale(self.x, self.y)
        sprite = SpriteHandler.get("flame")
        client.window.surface.blit(sprite, (localX * 64, localY * 64))
    
    def onCollision(self, entity):
        EntityProjectile.onCollision(self, entity)
        if isinstance(entity, EntityLiving):
            entity.addBuff(DamageBuff())